package com.recharge.web.controller;

import com.recharge.domain.vo.UserDetailDO;
import com.recharge.domain.vo.UserLoginDO;
import org.apache.shiro.SecurityUtils;

public class BaseController {

    public UserLoginDO getUserLoginInfo() {
        return (UserLoginDO) SecurityUtils.getSubject().getPrincipal();
    }
    
    public String getUserName() {
//        UserLoginDO user = getUserLoginInfo();
//        return user == null ? "" : user.getUsername();
        UserLoginDO user = getUserLoginInfo();
        if(user == null) return "";
        UserDetailDO userDetail = user.getUserDetailDO();
        return userDetail == null ? "" : userDetail.getRealName();
    }

    public String getUserMerchantId() {
        UserLoginDO user = getUserLoginInfo();
        if(user == null) return null;
        return user.getMerchantId();
    }
    
}
